function showVehicleTrafficRecordSearch() {
	window.location.href = "showVehicleTrafficRecordSearch.do";
}

function ajaxFindVehicleTrafficRecordSearchList(currentPage,pageSize) {
	$.ajax({
		type : "post",
		url : "ajaxVehicleTrafficRecordSearchList.do",
		data : {
			currentPage:currentPage,
			pageSize:pageSize,
		},
		success : function(msg) {
			$("#listVehicleTrafficRecordBox").html(msg);
		}
	});
}

function ajaxShowVehicleTrafficRecordEdit(id){
	$.ajax({
		type:"post",
		url:"ajaxShowVehicleTrafficRecordEdit.do",
		data:{vehicleTrafficRecordId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 800,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons : [{
					text : "保存",
					click : function() {
						ajaxSaveVehicleTrafficRecord(this);
					}
				}, {
					text : "关闭",
					click : function() {
						$(this).dialog("close");
					}
				}]
			});
		}
	});
}

function ajaxSaveVehicleTrafficRecord(objDialog) {
	vehicleTrafficRecordValidate();
	if ($("#frmVehicleTrafficRecord").valid()) {
		$(objDialog).dialog("close");
		var options ={
				type: "post",
				url : "ajaxSaveVehicleTrafficRecord.do",
				success: function () {
					clearInput("#sltVehicleTrafficRecord");
					ajaxFindVehicleTrafficRecordSearchList(1);
					showMessageDialog("保存车辆通行记录","车辆通行记录信息保存成功。",null,dialogType.info);
				}
		};
		var i = 0;
		$("#vehicleDialog tbody input[type='hidden']").each(
				function () {$(this).attr("name","illegalVehicleInfoList["+ i++ +"].id");}
		);
		$("#frmVehicleTrafficRecord").ajaxSubmit(options);
	}
}

function ajaxShowVehicleTrafficRecordView(id){
	$.ajax({
		type:"post",
		url:"ajaxShowVehicleTrafficRecordView.do",
		data:{vehicleTrafficRecordId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 620,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons: [
				          {
				        	  text: "关闭",
				        	  click: function() {
				        		  $(this).dialog( "close" );
				        	  }
				          }
				          ]
			});
		}
	});
}

function ajaxDeleteVehicleTrafficRecordById(id) {
	var VehicleTrafficRecordIds="";
	var sltCD = $("#listVehicleTrafficRecordList tbody input:checked").length;
	if(id==null){
		$("#listVehicleTrafficRecordList tbody input:checked").each(function(){ 
			VehicleTrafficRecordIds += $(this).val()+";";
		});
		if(sltCD == 0){
			showMessageDialog("提示","请选择一行或多行",null,dialogType.info);
			return;
		}else{
			VehicleTrafficRecordIds = VehicleTrafficRecordIds.substring(0, VehicleTrafficRecordIds.length-1);
		} 
	}else{
		VehicleTrafficRecordIds=id;
		sltCD = 1;
	}
	if( VehicleTrafficRecordIds!=null){
		showMessageDialog("删除车辆通行信息","确定要删除所选“"+sltCD+"”条车辆通行信息记录吗？",
				function () {
			$.ajax({     
				type:"post",
				url:"ajaxDeleteVehicleTrafficRecordByIds.do",
				data:{VehicleTrafficRecordIds:VehicleTrafficRecordIds},
				success:function(msg){
					ajaxFindVehicleTrafficRecordSearchList();
					showMessageDialog("提示","车辆通行信息删除成功",null,dialogType.info);
				}
			});
		}
		,dialogType.warning);
	}
}

